import { Flex, Tag, Tooltip } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

import CopyTextButton from "@/components/common/copyTextButton"
import TooltipText from "@/components/common/tooltipText"
import { formatTime } from "@/utils/util"

const memberRebateStatus = (newFormat: (arg: string) => string): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	memberRebateStatus_superiorAgent: {
		key: "memberRebateStatus_superiorAgent",
		align: "center",
		dataIndex: "parentProxyName",
		title: newFormat("risk.direct_agent"),
		width: 200,
		render: (superiorAgent: string) => <CopyTextButton text={superiorAgent} />
	},
	memberRebateStatus_majorAgentAccount: {
		key: "memberRebateStatus_majorAgentAccount",
		align: "center",
		dataIndex: "topProxyName",
		title: newFormat("risk.belonging_general_agent"),
		width: 200,
		render: (superiorAgent: string) => <CopyTextButton text={superiorAgent} />
	},
	memberRebateStatus_accountStatus: {
		key: "memberRebateStatus_accountStatus",
		dataIndex: "accountStatus",
		title: newFormat("label.member.account_status"),
		align: "center",
		width: 120,
		render: (text: string, record: any) =>
			(() => {
				let context: string = ""
				let color = "green"
				if (record.paymentLockStatus) {
					context = newFormat("label.account_lock_status")
					color = "gold"
				} else if (record.loginLockStatus) {
					context = newFormat("label.login_lock_status")
					color = "volcano"
				} else if (record.gameLockStatus) {
					context = newFormat("label.game_lock_status")
					color = "geekblue"
				} else {
					context = newFormat("label.account_status_normal")
					color = "green"
				}

				return (
					<span>
						<Tag style={{ textAlign: "center" }} color={color}>
							<TooltipText width={70} text={context} />
						</Tag>
					</span>
				)
			})()
	},
	memberRebateStatus_memberTag: {
		key: "memberRebateStatus_memberTag",
		align: "center",
		dataIndex: "userLabel",
		title: newFormat("risk.member_tag"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_riskControlLevel: {
		key: "memberRebateStatus_riskControlLevel",
		align: "center",
		dataIndex: "windControlName",
		title: newFormat("risk.risk_control_level"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_rebateFrozenTime: {
		key: "memberRebateStatus_rebateFrozenTime",
		align: "center",
		dataIndex: "freezeAt",
		title: newFormat("risk.rebate_frozen_time"),
		width: 100,
		render: (rebateFrozenTime: string) => formatTime(rebateFrozenTime)
	},
	memberRebateStatus_frozenOperatedBy: {
		key: "memberRebateStatus_frozenOperatedBy",
		align: "center",
		dataIndex: "freezeBy",
		title: newFormat("risk.frozen_operated_by"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_rebateUnfrozenRemark: {
		key: "memberRebateStatus_rebateUnfrozenRemark",
		align: "center",
		dataIndex: "freezeRemark",
		title: newFormat("risk.rebate_unfrozen_remark"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_rebateUnfrozenTime: {
		key: "memberRebateStatus_rebateUnfrozenTime",
		align: "center",
		dataIndex: "unfreezeAt",
		title: newFormat("risk.rebate_unfrozen_time"),
		width: 100,
		render: (rebateUnfrozenTime: string) => formatTime(rebateUnfrozenTime)
	},
	memberRebateStatus_rebateUnfrozenBy: {
		key: "memberRebateStatus_rebateUnfrozenBy",
		align: "center",
		dataIndex: "unfreezeBy",
		title: newFormat("risk.rebate_unfrozen_by"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_thawNotes: {
		key: "memberRebateStatus_thawNotes",
		align: "center",
		dataIndex: "unfreezeRemark",
		title: newFormat("risk.thaw_notes"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},

	memberRebateStatus_memberAccount: {
		key: "memberRebateStatus_memberAccount",
		align: "center",
		dataIndex: "memberAccount",
		title: newFormat("risk.member_account"),
		width: 150,
		render: (memberAccount: string) => <CopyTextButton text={memberAccount} />
	},
	memberRebateStatus_orderNumber: {
		key: "memberRebateStatus_orderNumber",
		align: "center",
		dataIndex: "orderNumber",
		title: newFormat("risk.order_number"),
		width: 100,
		render: (orderNumber: string) => <CopyTextButton text={orderNumber} />
	},
	memberRebateStatus_accountType: {
		key: "memberRebateStatus_accountType",
		align: "center",
		dataIndex: "accountType",
		title: newFormat("risk.account_type"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_belongingMerchant: {
		key: "memberRebateStatus_belongMerchant",
		align: "center",
		dataIndex: "belongMerchant",
		title: newFormat("label.belong_merchant"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_directAgent: {
		key: "memberRebateStatus_directAgent",
		align: "center",
		dataIndex: "directAgent",
		title: newFormat("risk.direct_agent"),
		width: 100,
		render: (directAgent: string) => <CopyTextButton text={directAgent} />
	},
	memberRebateStatus_belongingGeneralAgent: {
		key: "memberRebateStatus_belongingGeneralAgent",
		align: "center",
		dataIndex: "belongingGeneralAgent",
		title: newFormat("risk.belonging_general_agent"),
		width: 100,
		render: (belongingGeneralAgent: string) => <CopyTextButton text={belongingGeneralAgent} />
	},
	memberRebateStatus_frozenRebatePeriod: {
		key: "memberRebateStatus_frozenRebatePeriod",
		align: "center",
		dataIndex: "frozenRebatePeriod",
		title: newFormat("risk.frozen_rebate_period"),
		width: 100,
		render: (frozenRebatePeriod: string) => formatTime(frozenRebatePeriod)
	},

	memberRebateStatus_venueName: {
		key: "memberRebateStatus_venueName",
		align: "center",
		dataIndex: "venueName",
		title: newFormat("risk.venue_name"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},

	memberRebateStatus_venue: {
		key: "memberRebateStatus_venue",
		align: "center",
		dataIndex: "venue",
		title: newFormat("risk.venue"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_gameName: {
		key: "memberRebateStatus_gameName",
		align: "center",
		dataIndex: "gameName",
		title: newFormat("risk.game_name"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_bettingTime: {
		key: "memberRebateStatus_bettingTime",
		align: "center",
		dataIndex: "bettingTime",
		title: newFormat("risk.betting_time"),
		width: 100,
		render: (bettingTime: string) => formatTime(bettingTime)
	},
	memberRebateStatus_bettingAmount: {
		key: "memberRebateStatus_bettingAmount",
		align: "center",
		dataIndex: "bettingAmount",
		title: newFormat("risk.betting_amount"),
		width: 100,
		render: (bettingTime: string) => `$${bettingTime}`
	},
	memberRebateStatus_validBet: {
		key: "memberRebateStatus_validBet",
		align: "center",
		dataIndex: "validBet",
		title: (
			<Flex vertical={false}>
				{newFormat("risk.valid_bet")}
				<Tooltip placement="top" title={newFormat("risk.valid_bets_tips")}>
					<div style={{ borderRadius: 999, backgroundColor: "black", width: 20, height: 20 }}>?</div>
				</Tooltip>
			</Flex>
		),
		width: 100,
		render: (validBet: string) => `$${validBet}`
	},
	memberRebateStatus_rebateRatio: {
		key: "memberRebateStatus_rebateRatio",
		align: "center",
		dataIndex: "rebateRatio",
		title: newFormat("risk.rebate_ratio"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_rebateAmount: {
		key: "memberRebateStatus_rebateAmount",
		align: "center",
		dataIndex: "rebateAmount",
		title: newFormat("risk.rebate_amount"),
		width: 100,
		render: (text: string) => <span> {text || "-"}</span>
	},
	memberRebateStatus_frozenRebateAmount: {
		key: "memberRebateStatus_frozenRebateAmount",
		align: "center",
		dataIndex: "frozenRebateAmount",
		title: newFormat("risk.frozen_rebate_amount"),
		width: 100,
		render: (frozenRebateAmount: string) => <div style={{ color: "red" }}>{`$${frozenRebateAmount}`}</div>
	}
})
export default memberRebateStatus
